package br.com.sistema.views.pessoa;

import br.com.sistema.models.EntidadeTipo;

import com.vaadin.data.util.BeanItemContainer;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;

public class PessoaPesquisaView {

	VerticalLayout component = new VerticalLayout();
	
	private BeanItemContainer<EntidadeTipo> entiTipoIdBeanContainer = 
			new BeanItemContainer<EntidadeTipo>(EntidadeTipo.class);
	
	// campos pesquisa
	private TextField entiNome = new TextField("Nome");
	private TextField entiCpf = new TextField("CPF");
	private ComboBox entiSexo = new ComboBox("Sexo");
	private ComboBox entiTipoId = new ComboBox("Tipo");
	
	public PessoaPesquisaView() {
		
		//confirma.setClickShortcut(KeyCode.ENTER);
		//confirma.setDisableOnClick(true);

		entiSexo.addItem("");
		entiSexo.addItem("M");
		entiSexo.addItem("F");
		entiSexo.setItemCaption("", "");
		entiSexo.setItemCaption("M", "Masculino");
		entiSexo.setItemCaption("F", "Feminino");
		entiSexo.setImmediate(true);
		entiSexo.setNullSelectionAllowed(false);
		entiSexo.setWidth("90");
		entiSexo.setValue("");
		
		entiTipoId.setImmediate(true);
		entiTipoId.setTextInputAllowed(false);
		entiTipoId.setNullSelectionAllowed(true);
		entiTipoId.setItemCaptionPropertyId("entitiponome");
		entiTipoId.setContainerDataSource(entiTipoIdBeanContainer);
		
		entiNome.setWidth("300");
		
		
		//VerticalLayout v = new VerticalLayout();
		//v.setSpacing(false);
		//v.setMargin(false);
		
		HorizontalLayout h0 = new HorizontalLayout();
		h0.setSpacing(true);
		
		FormLayout f0 = new FormLayout();
		f0.addComponent(entiTipoId);
		f0.addComponent(entiNome);
		h0.addComponent(f0);
		
		FormLayout f1 = new FormLayout();
		f1.addComponent(entiSexo);
		f1.addComponent(entiCpf);
		h0.addComponent(f1);
		
		component.addComponent(h0);
		
	}
	
	public VerticalLayout getComponent(){
		return this.component;
	}

	public TextField getEntiNome() {
		return entiNome;
	}

	public TextField getEntiCpf() {
		return entiCpf;
	}

	public ComboBox getEntiSexo() {
		return entiSexo;
	}
	
	public ComboBox getEntiTipoId(){
		return entiTipoId;
	}

	public BeanItemContainer<EntidadeTipo> getEntiTipoIdBeanContainer() {
		return entiTipoIdBeanContainer;
	}
	
	
}
